# How to make an AI Chatbot in Coda

**URL:** <https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010>\
**Category:** Tips and Hacks\
**Created:** [January 24, 2024, 10:52am UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010 "2024-01-24T10:52:46Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [January 24, 2024, 10:52am UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/1 "2024-01-24T10:52:46Z")

</div>

![image](https://global.discourse-cdn.com/coda1/original/3X/7/0/70d5f37be05933a6e2f5848258f63be2ccc76e8d.png)

You cannot normally have a **chat** with Coda AI inside your workflows. When you set a column in a table to use Coda AI, you can provide a formula that provides the prompt, but it does not remember any of the previous prompts or responses - so it has no context to help it understand the current prompt better.

When you click the AI Refresh button or execute the `RefreshAssistant()` formula, the AI has no ‘memory’ of the previous exchanges - and so loses all that context.

But is **is possible** to give that context to the AI engine. The convention used by LLMs is to provide the previous prompt/response pairs in the current prompt. You label the queries with “USER:” and the responses with “BOT:” and the LLM understands this to be a complete conversation to be used to provide the context for the query.

In the example above, you will notice that each question assumes the AI remembers all the previous exchanges. So references to “this”, “there”, “that monastery”, are understood. When it is asked “And the ecomony?” it understands from the context that it is the economy of Greece that is being refered-to.

To achieve this, there is a hidden column called `Prompt` that is the actual prompt given to Coda AI for each row. That column has a formula that gathers all the previous exchanges and labels tham with “USER:” and “BOT:” and this ‘reminds’ the LLM of the conversation that is to be used to provide context for the questions.

 ![image](https://global.discourse-cdn.com/coda1/original/3X/1/2/125d2a5e3215c2096508bffd8fd6efd5410443e0.png)

This results in this `Prompt` for the last question from the example above;

 ![image](https://global.discourse-cdn.com/coda1/original/3X/7/e/7ed0777ef505c6a4c16ca093a27dcc6242389a95.png)

The AI settings for the `Response` column is set as follows. By setting the length to a single sentence, a better conversation ensues. Longer responses would contain many repetitions of previously provided information.

![image](https://global.discourse-cdn.com/coda1/original/3X/3/d/3dc13a8e784181748fc3907026ccf1585940570c.png)

Note how the queries are short, simple and direct, but the responses are germaine and to-the-point.

The button simply does `RefreshAssistant(Response)` and adds a row if its the last row of the table.

This approach provides Coda users with a form of AI interaction they will be very familiar with from ChatGPT and other chat-based AI platforms.

Max

---

<div class="post-metadata">

**Author:** ![Bill\_French](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/bill_french/32/49422_2.png) [@Bill\_French](https://connect.superhuman.com/u/Bill_French)\
**Post date:** [January 24, 2024, 1:06pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/2 "2024-01-24T13:06:10Z")

</div>

> [@Max\_OBrien](#):
>
> This approach provides Coda users with a form of AI interaction they will be very familiar with

About a year ago I created a similar approach, but it was not performant at all. It was so slow that no one in my company would tolerate it.

How well does your version respond?

---

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [January 24, 2024, 1:24pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/3 "2024-01-24T13:24:42Z")

</div>

we have had no complaints regarding performance.  
i have not done any measurements,  
but it feels like under a second per row,  
which is fast enough for our use-cases

---

<div class="post-metadata">

**Author:** ![Nina\_Ledid](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/nina_ledid/32/23875_2.png) [@Nina\_Ledid](https://connect.superhuman.com/u/Nina_Ledid)\
**Post date:** [January 24, 2024, 5:18pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/4 "2024-01-24T17:18:01Z")

</div>

Ahh, @Max_OBrien, time and time again your implementations amaze me. Thanks so much for taking all of us along in your discovery journey and for sharing your insights!

---

<div class="post-metadata">

**Author:** ![Bill\_French](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/bill_french/32/49422_2.png) [@Bill\_French](https://connect.superhuman.com/u/Bill_French)\
**Post date:** [January 25, 2024, 4:36pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/5 "2024-01-25T16:36:44Z")

</div>

> [@Max\_OBrien](#):
>
> ve had no complaints regarding performance.

Wonderful. My approach was gated by all sorts of things including Coda AI itself which was only an vague idea when I first tried this in early 2023.

It’s nice to see it is more practical now and the idea that conversations could exist in a data-centric framework is even more compelling.

Firebase also supports the idea that conversational AI solutions should begin and end inside the data. Firebase AI extensions make this possible. Simply store a prompt into a field and watch as the database becomes the agent, complete with history, multi-turn inferences, and even a baked in ability to support unlimited conversational threads.

> **[All extensions | Firebase Extensions Hub](https://extensions.dev/extensions?category=ai)**

---

<div class="post-metadata">

**Author:** ![Robert\_Collett](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/robert_collett/32/33455_2.png) [@Robert\_Collett](https://connect.superhuman.com/u/Robert_Collett)\
**Post date:** [January 25, 2024, 11:11pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/6 "2024-01-25T23:11:39Z")

</div>

Can you have the sort of conversations you can within ChatGPT with prompts and responses being several thousand words long?

---

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [January 26, 2024, 8:59am UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/7 "2024-01-26T08:59:31Z")

</div>

yes.

by changing the ai-settings of the response column.  
i set its length to single sentence, but it can me longer.

---

<div class="post-metadata">

**Author:** ![Andrew\_Farnsworth](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/andrew_farnsworth/32/27829_2.png) [@Andrew\_Farnsworth](https://connect.superhuman.com/u/Andrew_Farnsworth)\
**Post date:** [February 21, 2024, 8:01pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/8 "2024-02-21T20:01:59Z")

</div>

Nice one, @Max_OBrien. How fast does this burn through credits?

---

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [February 21, 2024, 9:02pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/9 "2024-02-21T21:02:40Z")

</div>

i have not measured that because i use the unlimited credits option.  
and i insist all my clients do the same.  
i cannot afford an automation that uses ai to suddenly stop working due to credits expired.  
i believe to unlimited credit option is good value when you start to exploit coda ai in your workflows.

simply doing the initial “prompt engineering” to get the ideal prompt for a use-vase would burn through a lot of credits before you started to get any business benefits

---

<div class="post-metadata">

**Author:** ![Davide\_445](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/davide_445/32/29360_2.png) [@Davide\_445](https://connect.superhuman.com/u/Davide_445)\
**Post date:** [March 31, 2024, 7:31am UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/10 "2024-03-31T07:31:42Z")

</div>

@Max_OBrien will be possible for the user to ask generating a text block using LLM on a document knowledge base (so i.e using RAG on documents like txt or MS Word documents).

---

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [March 31, 2024, 3:01pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/11 "2024-03-31T15:01:07Z")

</div>

in principal yes.

but it would be easier to just add your content (the text from your ms word docs and other texts) directly to top of your prompt via a formula.

however…

there are limits to how much of your prompt text will be used by coda ai.

i dont know how much of the context window is consumed by coda’s own prompt content, and how much remains for you to use.

so you need to experiment. but i suspect the limitation of the current version of coda ai will not support much text from your word docs.

and you will need to pay for the unlimited ai credits or you will run put before you have even got your prompts figured out.

max

---

<div class="post-metadata">

**Author:** ![Davide\_445](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/davide_445/32/29360_2.png) [@Davide\_445](https://connect.superhuman.com/u/Davide_445)\
**Post date:** [March 31, 2024, 3:11pm UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/12 "2024-03-31T15:11:18Z")

</div>

You think will be easier to integrate a third party LLM?

Honestly since some months I’m not using GPT anymore for my LLM-related activities, passing on Mistral (various models) and Claude (2, 2.1 and now 3 different options).

Having a complete LLM+RAG pipeline outside Coda (but integrated with Coda UI) will be probably much more flexible than using current Coda native AI features (limited so some use cases in my understanding).

---

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [April 1, 2024, 5:58am UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/13 "2024-04-01T05:58:05Z")

</div>

the purpose and scope of my original post was to simulate the conversational form of interaction with Coda AI, simular to platforms such as ChatGPT etc.

it is not intended to extend the paradigm to RAG or agents etc.

so you are most likely to need to use packs to progress in that direction.

max

---

<div class="post-metadata">

**Author:** ![Bjorn\_Hansell](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/bjorn_hansell/32/17961_2.png) [@Bjorn\_Hansell](https://connect.superhuman.com/u/Bjorn_Hansell)\
**Post date:** [June 28, 2024, 3:10am UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/14 "2024-06-28T03:10:04Z")

</div>

@Max_OBrien, I have played with this method and find that the Coda AI often returns a response to the first prompt in a chain or sometimes it just repeats the prompts back to me. I made [a sample doc](https://coda.io/@bjornhansell/ai-conversation-test) with manually created prompts, where you can see these strange responses in row 4 and 8.

Another strange thing is that I consistently get the same response to a particular prompt in my test doc, but when I use the exact same prompts in another doc with the same settings, the quality of the AI responses is much lower. (Attaching a screen dump)

Any idea if I may be doing something wrong? Would you recommend using a pack instead to get better results?

 ![image](https://global.discourse-cdn.com/coda1/original/3X/e/5/e57c7f38e2342921ecbfec1886b543bf8fb9df1e.png)

---

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [June 29, 2024, 7:36am UTC](https://connect.superhuman.com/t/how-to-make-an-ai-chatbot-in-coda/46010/15 "2024-06-29T07:36:41Z")

</div>

this looks more like an issue with my formula than a problem with coda ai.  
i am travelling at sea a.t.m with variable internet bandwith.  
so i will look into this early next week.

max
