Using of Converse API

i tried to use Converse API
POST http://<my_domain>/api/v1/bots/test/converse/132

but got error “The remote server returned an error: (400) Bad Request.”

how i can use Converse API and how i can get user id value

Hi @ktharwat , with curl you must specify the Content-Type to be application/json

Something like:

curl -d "{\"type\":\"text\",\"text\":\"Hey!\"}" -H "Content-Type: application/json" -X POST http://localhost:3000/api/v1/bots/test/converse/my_id

I need to test it with another client, before raising a PR to the documentation if that header is required.

Regarding the user_id, generate any random user and keep it in usage for your session.

i already added the Content-Type, but still got Bad request


Umm, I don’t know which client you use, but can you send the actual request?

I guess you use the master, so you can debug from the server-side.

In the root folder

yarn cmd watch:core

Then add'validatePayload ' + JSON.stringify(req.body)) before this line

Then restart your server from another console.

yarn start

You would be able to see what it gets.

here is my client code

in main function of project

json = "{\"type\":\"text\",\"text\":\"Hey!\"}}";
result = APIPOST(domain + "/api/v1/bots/test/converse/123654", json, token, false);
protected string APIPOST(string url, string json, string token, bool auth)
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "POST";
            if (token != null)
                httpWebRequest.Headers.Add("Authorization", @"bearer " + token);
                httpWebRequest.Headers.Add("X-BP-Workspace", @"default");

            if (!string.IsNullOrWhiteSpace(json))
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    var result = streamReader.ReadToEnd();

                    if (auth)
                        APIResponse apiResponse = new JavaScriptSerializer().Deserialize<APIResponse>(result);
                        token = apiResponse.payload["token"];
                        return token;
                    return result;
            catch (Exception ex)
                return ex.Message;


I hope you have test bot existing.

If it exists, then ensure the token is null, also the domain should be something like http://localhost:3000 and not just the hostname.

Otherwise, please read the answers in here to get the actual HTTP traffic, if you can’t use a proxy (e.g. Charles), or you can’t sniff the traffic (by e.g. Wireshark).

Also, use curl, so you can test from the command line, check my first answer for the command used.

i am able to fix the issue by removing an additional ‘}’ in the body!

Dear All ,

I am new to use Converse API , i checked Documentation and found that i have to use : POST /api/v1/bots/{botId}/converse/{userId} , but actually i do not know how could i get the user ID or what it represents , May you clarify the way to obtain it , please ? Thanks in advance

Hi @Hebatalla and welcome to the community.

As mentioned in the docs, the user_id is simply anything unique, you can use random one, e.g. myuser12345, but you need to ensure it is not duplicated.

You can also append it with timestamp, e.g. user_system_87271616234, where the number is the timestamp now, something like new Date().getTime()

1 Like

@asashour how can I secure my Converse API requests?