> For the complete documentation index, see [llms.txt](https://tine.thingsme.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tine.thingsme.xyz/recipes/ollama_chatbot.md).

# OLLAMA Telegram Bot

Create Telegram chat bot with OLLAMA

### Generates text responses via OLLAMA from user's message.

{% hint style="info" %}
Replace `_YOUR_TELEGRAM_BOT_TOKEN_`, `_OLLAMA_HOST_`, and `_OLLAMA_PORT_` from the below example with yours. And the "model" parameter of flows.ollama should be pulled in advance.
{% endhint %}

**chatbot.toml**

```toml
[log]
    level = "info"

[[inlets.telegram]]
    token = "_YOUR_TELEGRAM_BOT_TOKEN_"
    debug = false
    timeout = "1s"

## inlets.telegram set the "text" field for the received message,
## change the field name from "text" to "prompt" which is expected by flows.ollama
## inlets.telegram set the "photo" field for the image file attached  in the message.
## change the field name from "photo" to "image" which is expected by flows.ollama
[[flows.update]]
    set = [
        { field = "text", name = "prompt" },
        { field = "photo", name = "image" },
    ]

[[flows.ollama]]
    address = "http://_OLLAMA_HOST_:_OLLAMA_PORT_"
    timeout = "120s"
    model = "phi3"
    stream = false

## flows.ollama yield a record that has "response" field for the result
## outlets.telegram is expecting "text" for outgoing message.
[[flows.update]]
    set = [
        { field = "response", name = "text"}
    ]

[[outlets.telegram]]
    token = "_YOUR_TELEGRAM_BOT_TOKEN_"
```

**Telegram**

<figure><img src="https://2482568086-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrX74soo3dvrOvMULBO8X%2Fuploads%2Fgit-blob-cc7c7069d300b9ddbb43daef61ae92f20c2ee012%2Follama-telegram.jpeg?alt=media" alt="" width="363"><figcaption><p>Telegram Chat Bot with OLLAMA</p></figcaption></figure>
