API integrations

I am facing several problems while integration API with botpress.

  1. Where I can find the user id?
  2. Where I can know the endpoint of a bot to send and receive messages using postman
  3. If possible tell me steps to integrate API.

Thank you @Nadine_Ungerer @spgin

Hello Cyborg33

Thanks for your questions. If one of the answers is not clear enough I will try to clarified it :stuck_out_tongue:

In an action or a hook, you can get the userId like this

The userID depends on the system (Frontend or Backend). On which system you want to get the USERID :smiley:?

Each module have there own endpoint to send a message

### Send Message

## Name the bot
@BOTID = weather

## Name of the module you want to send a message
@MODULE_NAME = channel-web 
POST {{baseUrl}}/api/v1/bots/{{BOTID}}/mod/{{MODULE_NAME}}/messages?__ts=1625664902473
Authorization: Bearer {{authToken}}
Content-Type: application/json

{"webSessionId":"/guest#YV55Eqb_IkzH5G0uAAA-","payload":{"type":"text","text":"hello"}}

Where to find your Bot Name

In botpress in you open the list bot you will find the name of your bot.

Click on the bot you want to know the @BOTID it will appear in the URL (highlighted in blue).

In this example, the Display name is Display Name of the Bot and the @BOTID is real-bot-id

I’m not sure about this one. Are you looking to create a custom-module?

Do you want to use the API in an Action Module?

If you want, you can provide more information on what you are trying to achieve and I will try to answer It.

Thanks

Thank you for your reply.

Actually, I am python developer and I want to integrate botpress with the backend where I can send message to botpress and I can get response from bot.

Still, I am facing some issues

  1. I tried to follow converse api and I get below response(error)

Where I can get this session id I tried to find it in config files but I unable to find it

3.Authorization: Bearer {{authToken}} Solved Thanks
4.

Is it static ? if not where we can find this?

@Daehli Thank you :slight_smile:

Hello Cyborg33

__TS

The __ts= is not static. The channel-web module adds this value. You can find the code here

The ?__ts=<timestamp_value> is parameters for the post request. It’s not mandatory you can remove it if you want.

The converse API is a better solution. In the example, I was assuming you want to post directly to a certain module (messenger or Microsoft teams).

webSessionId

The webSessionId is a value generate by the channel-web module. You can find the code here

If you are using the converse API this Key/value is not mandatory in the post request.

If you need it. You can go on your botpress website and open the developer console. You can type window.__BP_VISITOR_SOCKER_ID. It’s only required for the channel-web module.

@Daehli Thank you so much for your help. Now I am getting responses from botpress API.