Converse API: What else than text?

Hi,

we use the converse API to use our own chat frontend together with botpress.

My question, is it possible to send something else than a message text to the bot by using the converse API?

I have some buttons which have a visible text and a hidden 8 digit long id and I have to send the id to the bot by clicking the button, because we have to use this id as a param for an API call to get the correct result.

Bildschirmfoto 2020-08-27 um 08.49.26

The visible part is the text of the link, but internally we have to use the ID which is an attribute of the button.

Thanks in advance
Frank

@FrankDaze:

Hi You can use quick replies or dropdown for the same:

var dat = { title: dats, value: dats }

  dates.push(dat)
}
let data = {
  choices: dates,
  typing: false,
  listType: 'listDates'
}
var more = { title: 'More', value: 'More1' }
dates.push(more)
const payloads = await bp.cms.renderElement('builtin_single-choice', data, event)
await bp.events.replyToEvent(event, payloads)

}

In ‘dat’ object , use ‘value’ for your backend.

Something like this

image

you can get the value in RAW JSON emulator:

it comes under the JSON part

1 Like

Thanks for your answer. Is that format that you used in dat working with the conversion API as well?

Your answer helps me definitely to understand how to render a builtin_single-choice.
That is something that I tried yesterday on my own without success. :slight_smile:

@FrankDaze : I have used that in actions. Works in web channels

To answer my own initial question:

Unfortunately the Botpress converse API is only accepting type: “text” and nothing else.

I need to send a payload to the bot, so I’m trying now to use the channel-web api with our own middleware.

2 Likes

I agree with you, it’s a bit sad that converse api doesn’t let you send anything else than text. You can use the channel-web api but it’s quite not documented, le me know if you need some help.

Hi EFF, can you give me some code about this? may be sending a card or carousel.

check this post, that could help:

1 Like

hi @Nghia_Nguyen

1- Check Franks link this is a workaround
2- we have a messaging http api coming up soon, check our releases frequently

1 Like

thank you. I look forward to it.

Thank you. that’s great.

Although not very obvious, the converse API does allow for the use of custom event types and payloads.

You must go through the “Authenticated Route (Debug)”. Note: You may leave the includes empty if the purpose isn’t debugging!

In this example request, all the properties from the Body will be sent into the bp event payload:

A console.log of the received event in bp:

The same rules apply to this custom event as mentioned in the Acting Proactively page where

This event will be dispatched to the bot so you need to add a handler for it. If this event is not handled, it will be interpreted as a user message.

2 Likes

Hello,
Im unble to create converse API
I get bad request…can you please tell me step by step process to create converse api and Using that API how to create flow?
Thanks a lot in advance