| = ChatScript Component | |
| :doctitle: ChatScript | |
| :shortname: chatscript | |
| :artifactid: camel-chatscript | |
| :description: Chat with a ChatScript Server. | |
| :since: 3.0 | |
| :supportlevel: Stable | |
| :tabs-sync-option: | |
| :component-header: Only producer is supported | |
| //Manually maintained attributes | |
| :group: AI | |
| *Since Camel {since}* | |
| *{component-header}* | |
| The ChatScript component allows you to interact with https://github.com/ChatScript/ChatScript[ChatScript Server] and have conversations. This component is stateless and relies on ChatScript to maintain chat history. | |
| [NOTE] | |
| ==== | |
| Refer to the file https://github.com/apache/camel/blob/main/components/camel-chatscript/src/main/java/org/apache/camel/component/chatscript/ChatScriptMessage.java[`ChatScriptMessage.java`] for details and samples. | |
| ==== | |
| // component options: START | |
| include::partial$component-configure-options.adoc[] | |
| include::partial$component-endpoint-options.adoc[] | |
| include::partial$component-endpoint-headers.adoc[] | |
| // component options: END | |
| == Usage | |
| This component expects a JSON with the following fields: | |
| [source,json] | |
| ---- | |
| { | |
| "username": "name here", | |
| "botname": "name here", | |
| "body": "body here" | |
| } | |
| ---- | |
| The bot name comes from the endpoint, and the reply is the `reply` field of the message the producer returns. | |
| The following route sends the message body to the bot `Harry` as the user in the `user` header: | |
| [source,yaml] | |
| ---- | |
| - route: | |
| from: | |
| uri: direct:chat | |
| steps: | |
| - setBody: | |
| expression: | |
| simple: | |
| expression: '{"username": "${header.user}", "body": "${body}"}' | |
| - to: | |
| uri: chatscript:localhost:1024/Harry | |
| - log: | |
| message: "${body.reply}" | |
| ---- | |